package com.muyu.product.controller;

import com.muyu.common.core.domain.R;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.product.domain.pojo.ProductTypeAttrPO;
import com.muyu.product.domain.req.ProductTypeAttrReq;
import com.muyu.product.service.TypeAttrService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName TypeController
 * @Description 描述
 * @Author ShiYu.Cui
 * @Date 2024/3/31 10:00
 */
@RestController
@RequestMapping("product/typeAttr")
@Api(tags = "商品类型属性")
public class TypeAttrController extends BaseController {
    @Autowired
    private TypeAttrService typeAttrService;
    @GetMapping("/typeAttrList")
    @ApiOperation("商品类型属性列表")
    public R<List<ProductTypeAttrReq>> typeAttrList(@RequestParam Integer productTypeId){
        return typeAttrService.typeAttrList(productTypeId);
    }

    @GetMapping("/typeParameterList")
    @ApiOperation("商品类型参数列表")
    public R<List<ProductTypeAttrReq>> typeParameterList(@RequestParam Integer productTypeId){
        return typeAttrService.typeParameterList(productTypeId);
    }

    @DeleteMapping("/delTypeAttr")
    @ApiOperation("删除商品类型属性")
    public R delTypeAttr(@RequestParam Integer id){
        typeAttrService.delTypeAttr(id);
        return R.ok();
    }

    @PostMapping("/insertTypeAttr")
    @ApiOperation("添加商品类型属性")
    public R insertTypeAttr(@RequestBody ProductTypeAttrPO productTypeAttrPO){
        typeAttrService.insertTypeAttr(productTypeAttrPO);
        return R.ok();
    }

    @PostMapping("updateTypeAttr")
    @ApiOperation("修改商品类型属性")
    public R updateTypeAttr(@RequestBody ProductTypeAttrPO productTypeAttrPO){
        typeAttrService.updateTypeAttr(productTypeAttrPO);
        return R.ok();
    }
}
